package simco.framework.gui.graph.supp;

import java.awt.BasicStroke;

/**
 * Vyctovy typ definujici typ ohraniceni objektu
 * 
 * @author Matej Prokop, mythge@students.zcu.cz
 */
public enum BorderType
{
    SOLID, THICK, DASHED;

    /**
     * Delka cerchovane cary, resp. delka mezery mezi
     * dvema "cerchami"
     */
    public static final int DEF_DASH_SIZE = 5;

    /**
     * Miterlimit cerchovaneho ohraniceni objektu
     */
    public static final int DEF_MITERLIMIT = 10;
    
    /**
     * Tlouska normalniho ramu
     */
    public static final int NORMAL_WIDTH = 1;

    /**
     * Tlouska silnejsiho (vyraznejsiho) ramu
     */
    public static final int THICK_WIDTH = 2;

    /**
     * Stroke pouzity pro vykresleni normalniho ramu
     */
    private static BasicStroke solidStroke;
    
    /**
     * Stroke pouzity pro vyslneho (tlusteho)ramu
     */
    private static BasicStroke thickStroke;
    
    /**
     * Stroke pouzity pro vykresleni ramu, vizualizovaneho
     * cerchovanou carou
     */
    private static BasicStroke dashedStroke;

    static 
    {
        float[] dash = {DEF_DASH_SIZE};

        solidStroke = new BasicStroke(NORMAL_WIDTH,
                BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_ROUND,
                DEF_MITERLIMIT);

        thickStroke = new BasicStroke(THICK_WIDTH,
                BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_ROUND,
                DEF_MITERLIMIT);

        dashedStroke = new BasicStroke(NORMAL_WIDTH,
                BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_ROUND,
                DEF_MITERLIMIT, dash, 0);
    }

    /**
     * Vraci Stroke pro vykresleni ramu v zavislosti na 
     * pozadovanem typu ramu, jenz je prijat jako parametr.
     * 
     * @param type pozadovany typ ramu
     * @return Stroke urceny pro vykresleni tohoto typu ramu
     */
    public static BasicStroke getBorderStroke(BorderType type)
    {
        switch(type)
        {
            case SOLID: return solidStroke;
            case THICK: return thickStroke;
            default: return dashedStroke;
        }
    }
}
